<?php
namespace App\Controller;
use Think\Controller;
class LoginController extends Controller{
    //登出逻辑
    public function logout(){
        session(null);  //清空会话
        return array('code' => 0);
        }
    //登录逻辑
    public function login($username,$password){
        $data['username'] = $username;
        $data['password'] = $password;
        $info = M('ucenter_member') -> where($data) -> find();
        if($info){
            session('id',$info['id']); //将用户id保存在会话中
            session('role_id',$info['role_id']);    //将用户权限保存在会话中
                return array('code' => 0); 
            }else{
            return array('code' => 1);
            }
    }
}  